package com.nhncorp.pleiades.client;

import java.net.InetAddress;
import java.net.UnknownHostException;

import com.nhncorp.pleiades.common.Constants;

public class PleiadesUser {
  
  private String hostName;
  private int heartbeatPort;
  private String serviceName;
  boolean sessionDisable = false;
  
  public PleiadesUser(String serviceName) {
    this.serviceName = serviceName;
    try {
      this.hostName = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException e) {
      e.printStackTrace();
    }
  }

  public PleiadesUser(String serviceName, String hostName) {    
    this.serviceName = serviceName;
    this.hostName = hostName;
  }
  
  public PleiadesUser(String serviceName, String hostName, int heartbeatPort) {    
    this.serviceName = serviceName;
    this.hostName = hostName;
    this.heartbeatPort = heartbeatPort;
  }

  public String getHostName() {
    return hostName;
  }

  public void setHostName(String hostName) {
    this.hostName = hostName;
  }

  public String getServiceName() {
    return serviceName;
  }

  public void setServiceName(String serviceName) {
    this.serviceName = serviceName;
  }

  public boolean isSessionDisable() {
    return sessionDisable;
  }

  public void setSessionDisable(boolean disable) {
    this.sessionDisable = disable;
  }
  
  public String toString() {
    return (this.hostName + "," + this.serviceName + "," + this.sessionDisable);
  }

  public String getCreatorName() {
    return serviceName + Constants.SERVICE_DELIMETER + hostName + Constants.SERVICE_DELIMETER + heartbeatPort;
  }

  public int getHeartbeatPort() {
    return heartbeatPort;
  }

  public void setHeartbeatPort(int heartbeatPort) {
    this.heartbeatPort = heartbeatPort;
  }
}
